//package com.github.bridge.handler;
//
//import cn.org.bjca.anysign.components.bean.message.AnyWriteChallengeCodeReqMessage;
//import cn.org.bjca.anysign.components.bean.message.ChallengeCodePDFInfo;
//import cn.org.bjca.anysign.model.p2p.SignExtInfo;
//import cn.org.bjca.anysign.terminal.model.CachetInfo;
//import cn.org.bjca.anysign.terminal.model.SignRuleInfo;
//import cn.org.bjca.common.model.AttachmentInfo;
//import cn.org.bjca.common.model.DocumentExtType;
//import cn.org.bjca.common.model.GeneratePDFInfo;
//import cn.org.bjca.common.model.KWRuleInfo;
//import cn.org.bjca.seal.esspdf.client.message.ChannelMessage;
//import cn.org.bjca.seal.esspdf.client.tools.AnySignClientTool;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.io.FileUtils;
//import org.springframework.stereotype.Component;
//
//import java.io.File;
//import java.util.ArrayList;
//import java.util.List;
//
///**
// * @program: signature-bridge-service
// * @description:
// * @author: hui.zhang
// * @date: 2024/8/26 9:29 下午
// **/
//@Slf4j
//@Component
//@RequiredArgsConstructor
//public class CASignHandler {
//    static AnySignClientTool anySignClientTool = null;
//
//    private static String resourcesPath;
//
//    static String testEncDataPath;
//
//    static String testHtmlFilePath;
//
//    static String testPdfFilePath;
//
//    static String testXMLFilePath;
//
//    static String testImageFilePath;
//
//    static String outPdfsFilePath;
//
//    static String testSignedPdfFilePath;
//
//    public static void main(String[] args) throws Exception {
//        String ip = "223.70.139.221";
//        int port = 20880;
//        anySignClientTool = new AnySignClientTool(ip, port);
//
//        // 签名人信息
//        AnyWriteChallengeCodeReqMessage message = new AnyWriteChallengeCodeReqMessage();
//        message.setSignerName("张三");
//        message.setSignerTelephone("15249257763");
//        message.setIdCard("610581199511242213");
//        message.setIdType("1");//1为身份证，2为军官证，3为护照，4为户口本，5其他.
//        message.setAlgorithm("RSA");
//        //		message.setAlgorithm("SM2");
//        message.setPeriod(300);
//
//        // 渠道号
//        SignExtInfo signExtInfo = new SignExtInfo();
//        signExtInfo.setBussChannel("999999");
//        message.setSignExtInfo(signExtInfo);
//
//        // 附件、证据
//        List<AttachmentInfo> attachmentInfos = new ArrayList<AttachmentInfo>();
//        cn.org.bjca.common.model.AttachmentInfo attachmentInfo = new cn.org.bjca.common.model.AttachmentInfo();
//        attachmentInfo.setAttach(false);
//        byte[] attachContent = FileUtils.readFileToByteArray(new File("/Users/jzy/Desktop/Knife4j.pdf"));
//        attachmentInfo.setAttachContent(attachContent);
//        attachmentInfo.setAttachType(DocumentExtType.IMAGEGIF);
//        attachmentInfo.setEvidenceHash("1234567890");
//        attachmentInfos.add(attachmentInfo);
//
//        cn.org.bjca.common.model.AttachmentInfo evidence = new cn.org.bjca.common.model.AttachmentInfo();
//        evidence.setEvidence(false);
//        byte[] evidenceContent = FileUtils.readFileToByteArray(new File("/Users/jzy/Desktop/Knife4j.pdf"));
//        evidence.setAttachContent(evidenceContent);
//        evidence.setAttachType(DocumentExtType.IMAGEGIF);
//        evidence.setEvidenceHash("1234567890");
//        evidence.setIndex(1);
//        attachmentInfos.add(evidence);
//        message.setAttachmentInfos(attachmentInfos);
//
//        // 待签名PDF
//        List<ChallengeCodePDFInfo> pdfInfos = new ArrayList<ChallengeCodePDFInfo>();
//        ChallengeCodePDFInfo pdfinfo = new ChallengeCodePDFInfo();
//        GeneratePDFInfo generatePDFInfo = new GeneratePDFInfo();
//        byte[] docContent = FileUtils.readFileToByteArray(new File("/Users/jzy/Desktop/Knife4j.pdf"));
//        generatePDFInfo.setDocContent(docContent);
//        generatePDFInfo.setDocumentExtType(DocumentExtType.PDF);
//        pdfinfo.setGeneratePDFInfo(generatePDFInfo);
//        // 设置签名位置信息
//        pdfinfo.setSignSuleType("0");
//        KWRuleInfo kwRuleInfo = new KWRuleInfo();
//        kwRuleInfo.setKW("zhanghui");
//        kwRuleInfo.setPageno("1");
//        kwRuleInfo.setKWOffset("0");
//        kwRuleInfo.setKWPos("0");
//        kwRuleInfo.setKWXOffset("0");
//        kwRuleInfo.setKWYOffset("0");
//        pdfinfo.setKwRuleInfo(kwRuleInfo);
//        pdfInfos.add(pdfinfo);
//
//        message.setChallengeCodePDFInfos(pdfInfos);
//
//        // 公章信息，使用签章规则
//        List<CachetInfo> cachetInfos = new ArrayList<CachetInfo>();
//        CachetInfo cachetInfo = new CachetInfo();
//        cachetInfo.setTid("F68F464B34B1C79");
//        SignRuleInfo signRule = new SignRuleInfo();
//        signRule.setRuleType("2"); // 签章规则方式
//        cachetInfo.setSignRule(signRule);
//        cachetInfos.add(cachetInfo);
//
//        // 公章，使用外传图片，签名策略编号
////        CachetInfo cachetInfo2 = new CachetInfo();
////        cachetInfo2.setAppName("3F89508445039559");
////        cachetInfo2.setImage("R0lGODlhZAAyAJEAAAAAAP///+0LC////yH5BAEAAAMALAAAAABkADIAAAL/nI+py+0Po5xG0IuzZqLbDYZi4nXDN6aqVKLrC5NtrFoefdNUXh2t+eL9gLrK8FgaIZFFxNL2u3xsxmcy5qrOUFGp9ZbdXE/Q8WzR3V2ZtS"
////                + "+RzHPGM0S28giPj2Vz8fO+l5bH0UfnJnImJ5So+KbBhOfnmMeVROWz92hZt6U5mfhHGRK6hJE52JhWOBHFaMUKFusYiTkZgceoFRlWO4Tay"
////                + "/sL69pXVtqwq5fb63VKq3uKVqy8uozcqfAsyRsYrXWLTUJpOTqX6y18rTx" + "+vM03azJty8KmbSrv8preDLp637+onT9YPU7s2xZKF6GB"
////                +
////                "/OCscJPPnzWEwQqiA0ZGocaFhBU9bTqkjlvAed8eQrSTDV8lkiUdxOMC7NCWgfJSuWR4shRLNWjeQbgIzVePiU02cvzp65LPotJwAvXINCXDcTCeYpkqqirWIBINCm2zFSxLlCmI4gBqr5xVkzvZIeK0FlBbr2bBtSsa15jYuGrnLn37tUjdhVz5Rj1cBbHixYwbO95QAAA7");
////        SignRuleInfo signRuleInfo = new SignRuleInfo();
////        signRuleInfo.setRuleType("0"); // 关键字
////        KWInfo kwInfo = new KWInfo();
////        kwInfo.setKW("zhanghui");
////        kwInfo.setKWOffset("0");
////        kwInfo.setKWPos("0");
////        kwInfo.setPageno("1");
////        kwInfo.setXOffset("0");
////        kwInfo.setYOffset("0");
////        signRuleInfo.setKWRule(kwInfo);
////        cachetInfo2.setSignRule(signRuleInfo);
////        cachetInfos.add(cachetInfo2);
//
//        message.setIsUnit("true");
//        message.setCachetInfos(cachetInfos);
//
//        ChannelMessage channelMessage = anySignClientTool.anyWriteGenerateChallengeCode(message);
//        System.out.println("状态码：" + channelMessage.getStatusCode());
//        System.out.println("状态信息：" + channelMessage.getStatusInfo());
//
//    }
//
//
//}
